// -----------------------------------------------------------------------
//  <copyright file="ICaptchaService.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2024 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://www.dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2024-04-26 23:04</last-date>
// -----------------------------------------------------------------------

namespace DaprPlus.Security;

/// <summary>
/// 定义验证码服务
/// </summary>
public interface ICaptchaService
{
    /// <summary>
    /// 生成验证码
    /// </summary>
    /// <param name="id">验证码唯一标识</param>
    /// <param name="seconds">缓存秒数</param>
    /// <returns></returns>
    (string code, byte[] bytes) Generate(string id, int? seconds = null);

    /// <summary>
    /// 验证验证码
    /// </summary>
    /// <param name="id">验证码唯一标识</param>
    /// <param name="code">输入的验证码</param>
    /// <param name="removeIfSuccess">验证成功是否移除</param>
    /// <param name="removeIfFail">验证失败是否移除</param>
    /// <returns></returns>
    bool Validate(string id, string code, bool removeIfSuccess = true, bool removeIfFail = true);
}
